import { getAreaObj } from '@/utils/util'

export const importConfig = {
	tabSteps: [
		{
			label: '下载模板',
			download: '下载模板',
			active: 1,
			rules: [
				{
					label: '下载最新导入模板。共1个：',
					children: [
						{
							label: '《户籍人口信息表》',
							link: true,
							url: 'view_dpCrPopulation_downloadTemplate',
						},
					],
				},
			],
		},
		{
			label: '导入基础信息',
			description: '',
			uploadTip: '户籍人口',
			active: 2,
			url: 'view_dpCrPopulation_import',
			code: 3305,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
	],
}

export const searchConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '户籍地区',
			prop: 'crAreas',
			checkStrictly: true,
			type: 'AplidAreaSelect',
			span: 8,
		},
		{
			label: '户籍地址',
			prop: 'crAddress',
			type: 'input',
			span: 8,
		},
		{
			label: '姓名',
			prop: 'name',
			type: 'input',
			span: 8,
		},
		{
			label: '身份证号',
			prop: 'idCard',
			type: 'input',
			span: 8,
		},
		{
			label: '信息来源',
			prop: 'dataFrom',
			type: 'input',
			span: 8,
		},
	],
}

export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		{ label: '户籍区', prop: 'crAreaName' },
		{ label: '户籍街道', prop: 'crStreetName' },
		{ label: '户籍社区', prop: 'crCommunityName' },
		{ label: '姓名', prop: 'name' },
		{ label: '身份证号', prop: 'idCard' },
		{ label: '户籍地址', prop: 'crAddress' },
		{
			label: '电话',
			prop: 'phone',
		},
		{ label: '紧急联系人电话', prop: 'contactPhone' },
		{ label: '信息来源', prop: 'dataFrom' },
		{
			label: '操作',
			prop: 'menu',
			width: 200,
			fixed: 'right',
		},
	],
}

export const apiStr = {
	index: 'view_dpCrPopulation_page',
	import: 'view_dpCrPopulation_import',
	delete: 'view_dpCrPopulation_del',
	export: 'view_dpCrPopulation_export',
}
export const auth = {
	...apiStr,
	// 批量操作
	mulitSet: 'mulitSet',
}
export const baseConfig = {
	pageName: '户籍人口数据',
	dictcodes: [],
	rowKey: 'id',
	addLabel: '新增',
	tipLabel: 'name',
	exportMqTopic: '/ning/export/',
	api: apiStr,
	auth,
	paramsObj: {
    code:3305
  },
	menuBtn: [
		{
			icon: 'delete',
			label: '删除',
			type: 'danger',
			operate: 'delete',
			auth: auth.delete,
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '75%',
	},
	searchConfig,
	tableConfig,
	importConfig,
	beforeOnLoadFormate: async (query) => {
		return new Promise((resolve, reject) => {
			const areaObj = getAreaObj(query.crAreas, 'cr', 'get')
			resolve({
				...query,
				...areaObj,
				crAreas: undefined,
			})
		})
	},
}
